package com.uestc.repository;

import java.util.Date;
import java.util.Map;

import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import com.uestc.entity.ResearchPlatform;

public interface ResearchPlatformRepository extends JpaRepository<ResearchPlatform, Long>{

	public Page<ResearchPlatform> findByCategoryId(Long id,Pageable pageable);

	@Query(value="select * from research_platform where category_id=?1 and create_time < ?2 order by create_time DESC LIMIT 1",nativeQuery=true)
	public Map<String, Object> getPrevious(Long categoryId, Date createTime);
	
	@Query(value="select * from research_platform where category_id=?1 and create_time > ?2 order by create_time ASC LIMIT 1",nativeQuery=true)
	public Map<String, Object> getNext(Long categoryId, Date createTime);

	public Page<ResearchPlatform> findByCategoryIdOrderByCreateTimeDesc(Long id, Pageable pageable);
}
